package snafu.implementation.actions.turn.left;

import java.util.List;

import snafu.framework.actions.AbstractAction;
import snafu.framework.actions.Intention;
import snafu.framework.objects.WorldObject;
import snafu.framework.states.StateItself;
import snafu.framework.view.Access;
import snafu.framework.worlds.WorldMap;
import snafu.implementation.states.literals.direction.DirectionLiteral;
import snafu.implementation.states.literals.direction.DirectionLiteralItself;

public class TurnLeftAction extends AbstractAction {

	public TurnLeftAction(List<WorldObject> targets, Intention<?> intention) {
		super(targets, intention);
	}

	@Override
	public void execute(WorldMap worldMap) {
		StateItself state = (StateItself) agent.getState();
		
		Integer direction = state.getLiteral(DirectionLiteral.class, 0);
		Integer newDirection = worldMap.getNextLeftDirection(direction);
		
		state.setLiteral(new DirectionLiteralItself(newDirection, Access.PUBLIC));
	}

	@Override
	public String output() {
		return agent + " turns left";
	}

	@Override
	public boolean supportMultiTargets() {
		return false;
	}

}
